package com.bawei.websocketdemo.test;

import android.util.Log;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

/**
 * @Author : yaotianxue
 * @Time : On 2023/6/28 09:53
 * @Description : YaoWebSocketClient
 */
public class YaoWebSocketClient extends WebSocketClient {
    public YaoWebSocketClient(URI serverUri) {
        super(serverUri,new Draft_6455());
    }

    @Override
    public void onOpen(ServerHandshake handshakedata) {
        Log.d("ytx", "onOpen: 打开链接");

    }

    @Override
    public void onMessage(String message) {
        Log.d("ytx", "onMessage: 接受到消息"+message);
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
        Log.d("ytx", "onClose: 关闭链接");

    }

    @Override
    public void onError(Exception ex) {
        Log.d("ytx", "onError: 链接异常"+ex.getMessage());

    }
}
